<ul class="sf-menu">
	<?php if(!$this->admin): ?>
		<li><a href="#"><?php echo $this->translate->_("Please login to access the administration menu."); ?></a></li>
	<?php else: ?>
		<li>
			<a href="<?php echo $this->url(array("controller" => "members", "action" => "list-users"), "admin", true); ?>" class="sf-with-ul"><?php echo $this->translate->_("Members"); ?><span class="sf-sub-indicator"> &#187;</span></a>
			<ul>
				<li><dfn></dfn></li>
				<li><a href="<?php echo $this->url(array("controller" => "members", "action" => "add-user"), "admin", true); ?>"><?php echo $this->translate->_("Add user"); ?></a></li>
				<li><a href="<?php echo $this->url(array("controller" => "members", "action" => "list-users"), "admin", true); ?>"><?php echo $this->translate->_("List users"); ?></a></li>
			</ul>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "pets", "action" => "index"), "admin", true); ?>"><?php echo $this->translate->_("Pets"); ?></a>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "services", "action" => "index"), "admin", true); ?>"><?php echo $this->translate->_("Services"); ?></a>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "news", "action" => "index"), "admin", true); ?>"><?php echo $this->translate->_("News"); ?></a>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "products", "action" => "list-products"), "admin", true); ?>" class="sf-with-ul"><?php echo $this->translate->_("Products"); ?><span class="sf-sub-indicator"> &#187;</span></a>
			<ul>
				<li><dfn></dfn></li>
				<li><a href="<?php echo $this->url(array("controller" => "products", "action" => "import-products"), "admin", true); ?>"><?php echo $this->translate->_("Import products"); ?></a></li>
				<li><a href="<?php echo $this->url(array("controller" => "products", "action" => "list-products"), "admin", true); ?>"><?php echo $this->translate->_("List products"); ?></a></li>
			</ul>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-sets"), "admin", true); ?>" class="sf-with-ul"><?php echo $this->translate->_("Attributes"); ?><span class="sf-sub-indicator"> &#187;</span></a>
			<ul>
				<li><dfn></dfn></li>
				<?php foreach($this->sets->listAttributeSets() as $scope): ?>
					<?php
						// po pets scope
						if($scope['scope'] == 'po_pets') {
							$sort = array();
							$sets = array();
							foreach($this->sets->getAttributeSets('po_pets') as $k => $c) {
								$_t = Petolio_Service_Util::Tr($c['name']);
								$sort[$k] = $_t;
								$sets[] = array('value'=> $c['id'], 'name' => $_t);
							} array_multisort($sort, SORT_ASC, $sets);

						// po services scope
						} elseif($scope['scope'] == 'po_services') {
							$sort = array();
							$sets = array();
							foreach($this->sets->getAttributeSets('po_services') as $k => $c) {
								if(isset($c['group_name']) && strlen($c['group_name']) > 0) {
									$_t = array(Petolio_Service_Util::title_case(Petolio_Service_Util::Tr($c['group_name'])), Petolio_Service_Util::title_case(Petolio_Service_Util::Tr($c['name'])));
									$sort[0][$k] = $_t[0];
									$sort[1][$k] = $_t[1];
									$sets[] = array(
										'value' => $c['id'],
										'group' => $_t[0],
										'raw_group' => $c['group_name'],
										'name' => $_t[1]
									);
								}
							} array_multisort($sort[0], SORT_ASC, $sort[1], SORT_ASC, $sets);

						// other scopes
						} else {
							$sort = array();
							$sets = array();
							foreach($this->sets->getAttributeSets($scope['scope']) as $k => $c) {
								$_t = Petolio_Service_Util::Tr($c['name']);
								$sort[$k] = $_t;
								$sets[] = array('value'=> $c['id'], 'name' => $_t);
							} array_multisort($sort, SORT_ASC, $sets);

							// not relevant
							continue;
						}
					?>
					<li>
						<a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-sets", "scope" => $scope['scope']), "admin", true); ?>"><?php echo ucfirst(str_replace(array('po_', '_'), array('', ' '), $scope['scope'])); ?></a>
						<ul>
							<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "add-set", "scope" => $scope['scope']), "admin", true); ?>"><?php echo $this->translate->_("Add set"); ?></a></li>
							<li><dfn></dfn></li>
							<?php $group = null; ?>
							<?php foreach($sets as $idx => $set): ?>
								<?php if(isset($set['group'])): ?>
									<?php if($set['group'] != $group): ?>
										<?php if(!is_null($group)): ?></ul></li><?php endif; ?>
										<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-sets", "scope" => $scope['scope'], "group" => $set['raw_group']), "admin", true); ?>"><?php echo $set['group']; ?></a><ul>
										<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "add-set", "scope" => $scope['scope'], "group" => $set['raw_group']), "admin", true); ?>"><?php echo $this->translate->_("Add set"); ?></a></li>
										<li><dfn></dfn></li>
									<?php endif; ?>
									<li>
										<a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-attributes", "id" => $set['value']), "admin", true); ?>"><?php echo $set['name']; ?></a>
										<ul>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "edit-set", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("Edit set"); ?></a>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "delete-set", "id" => $set['value']), "admin", true); ?>" class="reqconf" title="<?php echo $this->translate->_("Are you sure you want to delete this attribute set?"); ?>"><?php echo $this->translate->_("Delete set"); ?></a>
											<li><dfn></dfn></li>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "add-attribute", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("Add attribute"); ?></a>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-attributes", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("List attributes"); ?></a>
										</ul>
									</li>
									<?php if($idx == count($sets) - 1): ?></ul></li><?php endif; ?>
									<?php $group = $set['group']; ?>
								<?php else: ?>
									<li>
										<a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-attributes", "id" => $set['value']), "admin", true); ?>"><?php echo $set['name']; ?></a>
										<ul>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "edit-set", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("Edit set"); ?></a>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "delete-set", "id" => $set['value']), "admin", true); ?>" class="reqconf" title="<?php echo $this->translate->_("Are you sure you want to delete this attribute set?"); ?>"><?php echo $this->translate->_("Delete set"); ?></a>
											<li><dfn></dfn></li>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "add-attribute", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("Add attribute"); ?></a>
											<li><a href="<?php echo $this->url(array("controller" => "attributes", "action" => "list-attributes", "id" => $set['value']), "admin", true); ?>"><?php echo $this->translate->_("List attributes"); ?></a>
										</ul>
									</li>
								<?php endif; ?>
							<?php endforeach; ?>
						</ul>
					</li>
				<?php endforeach; ?>
			</ul>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "0"), "admin", true); ?>" class="sf-with-ul"><?php echo $this->translate->_("Advertising"); ?><span class="sf-sub-indicator"> &#187;</span></a>
			<ul>
				<li><dfn></dfn></li>
				<li>
					<a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "0"), "admin", true); ?>"><?php echo $this->translate->_("System default"); ?></a>
					<ul>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-banner", "customer-type" => "0"), "admin", true); ?>"><?php echo $this->translate->_("Add banner"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "0"), "admin", true); ?>"><?php echo $this->translate->_("List banners"); ?></a></li>
					</ul>
				</li>
				<li>
					<a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "1"), "admin", true); ?>"><?php echo $this->translate->_("Pet sponsoring"); ?></a>
					<ul>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-customer", "type" => "1"), "admin", true); ?>"><?php echo $this->translate->_("Add customer"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-customers", "type" => "1"), "admin", true); ?>"><?php echo $this->translate->_("List customers"); ?></a></li>
						<li><dfn></dfn></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-banner", "customer-type" => "1"), "admin", true); ?>"><?php echo $this->translate->_("Add banner"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "1"), "admin", true); ?>"><?php echo $this->translate->_("List banners"); ?></a></li>
					</ul>
				</li>
				<li>
					<a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "2"), "admin", true); ?>"><?php echo $this->translate->_("Classical advertising"); ?></a>
					<ul>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-customer", "type" => "2"), "admin", true); ?>"><?php echo $this->translate->_("Add customer"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-customers", "type" => "2"), "admin", true); ?>"><?php echo $this->translate->_("List customers"); ?></a></li>
						<li><dfn></dfn></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-campaign"), "admin", true); ?>"><?php echo $this->translate->_("Add campaign"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-campaigns"), "admin", true); ?>"><?php echo $this->translate->_("List campaigns"); ?></a></li>
						<li><dfn></dfn></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "add-banner", "customer-type" => "2"), "admin", true); ?>"><?php echo $this->translate->_("Add banner"); ?></a></li>
						<li><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "list-banners", "customer-type" => "2"), "admin", true); ?>"><?php echo $this->translate->_("List banners"); ?></a></li>
					</ul>
				</li>
			</ul>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "translations", "action" => "list-translations"), "admin", true); ?>" class="sf-with-ul"><?php echo $this->translate->_("Translations"); ?><span class="sf-sub-indicator"> &#187;</span></a>
			<ul>
				<li><dfn></dfn></li>
				<li><a href="<?php echo $this->url(array("controller" => "translations", "action" => "add-translation"), "admin", true); ?>"><?php echo $this->translate->_("Add translation"); ?></a></li>
				<li><a href="<?php echo $this->url(array("controller" => "translations", "action" => "list-translations"), "admin", true); ?>"><?php echo $this->translate->_("List translations"); ?></a></li>
			</ul>
		</li>
		<li>
			<a href="<?php echo $this->url(array("controller" => "index", "action" => "logout"), "admin", true); ?>"><?php echo $this->translate->_("Logout"); ?></a>
		</li>
	<?php endif; ?>
</ul>
<div class="clear"></div>
<script type="text/javascript">
	READY(function(){
		$("body").bind("Admin", function(e){
			if(e.unveiled === true) {
				Admin.loadJs('menu/supersubs.js');
				Admin.loadJs('menu/superfish.js');

				if($('ul.sf-menu').children().length > 1)
					$('div.disable', 'div.menu').remove();

				$('ul.sf-menu').supersubs({
			        minWidth: 12,
			        maxWidth: 20,
			        extraWidth: 2
			    }).superfish({
				    delay: 500,
				    animation: { height:'show' },
				    speed: 'fast',
				    autoArrows: true,
				    dropShadows: false
				});
			}
		});
	});
</script>